<%--
    Document   : formTest
    Created on : 31.12.2012, 10:31:08
    Author     : Martin Zmítko <martin.zmitko@gmail.com>
--%>

<%@ include file="/WEB-INF/jsp/header.jsp" %>
<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>

        <c:if test="${testData.id != 0}">
            <form:form method="post" action="${pageContext.request.contextPath}/smazTest" class="pull-right">
                <input type="hidden" name="id" value="${testData.id}"/>
                <input type="submit" value="<spring:message code="form.remove" />" class="myBtn myBtn-warning" />
            </form:form>
        </c:if>
         
        <c:if test="${testData.id != 0}"> <h2>Editace testu - ${testData.name}</h2> </c:if>       
        <c:if test="${testData.id == 0}"> <h2>Přidání testu</h2> </c:if>
                
        <form:form class="form-horizontal" commandName="testData" action="test.do">
            <c:if test="${testData.id != 0}">
                <div class="control-group">
                    <label class="control-label" for="inputName"><spring:message code="form.id" />:</label>
                    <div class="controls">
                        <form:hidden path="id" readonly="true" /> <span>${testData.id}</span>
                    </div>
                </div>
            </c:if>
            <div class="control-group">
                <label class="control-label" for="inputName">Název:</label>
                <div class="controls">
                    <form:input path="name" id="inputName" />
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="inputDescr">Popis:</label>
                <div class="controls">
                    <form:textarea path="descr" id="inputDescr" />
                </div>
            </div>
                
                    <c:choose>
                        <c:when test="${testData.id == 0}">
                            <div class="control-group">
                                <label class="control-label" for="inputType">Typ testu:</label>
                                <div class="controls">
                                    <form:select path="types.id" id="inputType" >
                                        <form:option value=""><spring:message code="form.choose" /></form:option>
                                        <c:forEach var="r" items="${types}">
                                            <form:option value="${r.id}">${r.name} </form:option>
                                        </c:forEach>
                                    </form:select>
                                </div>
                            </div>         
                            <div class="control-group">
                                <label class="control-label" for="inputNumber">Počet otázek:</label>
                                <div class="controls">
                                    <form:input path="number" id="inputNumber" />
                                </div>
                            </div>
                        </c:when>
                        <c:otherwise>
                            <div class="control-group">
                                <label class="control-label" for="inputType">Typ testu:</label>
                                <div class="controls">
                                     <form:hidden path="types.id" readonly="true" /> <span>${testData.types.name}</span>
                                </div>
                            </div>         
                            <div class="control-group">
                                <label class="control-label" for="inputNumber">Počet otázek:</label>
                                <div class="controls">
                                    <form:hidden path="number" readonly="true" /> <span>${testData.number}</span>
                                </div>
                            </div>
                        </c:otherwise>
                    </c:choose>     
                
         
            <div class="control-group">
                <div class="controls">
                    <input type="submit" value="<spring:message code="form.generateTest" />" class="myBtn" />
                </div>
            </div>
        </form:form>



<%@ include file="/WEB-INF/jsp/footer.jsp" %>